import install from './install';
import Store from './store'
//这个文件是入口文件，核心就是导出所有写好的方法
export function mapState(stateList) {
  let obj = {};
  for (let i = 0; i < stateList.length; i++) {
    let stateName = stateList[i];
    obj[stateName] = function () {
      return this.$store.state[stateName];
    };
  }
  return obj;
}
export function mapGetters(gettersList) {
  let obj = {};
  for (let i = 0; i < gettersList.length; i++) {
    let getterName = gettersList[i];
    obj[getterName] = function () {
      return this.$store.getters[getterName];
    };
  }
  return obj;
}
export function mapMutations(mutationList) {
  let obj = {};
  for (let i = 0; i < mutationList.length; i++) {
    obj[mutationList[i]] = function (payload) {
      this.$store.commit(mutationList[i], payload);
    };
  }
  return obj;
}
export function mapActions(actionList) {
  let obj = {};
  for (let i = 0; i < actionList.length; i++) {
    obj[actionList[i]] = function (payload) {
      this.$store.dispatch(actionList[i], payload);
    };
  }
  return obj;
}
//export default导出的对象不支持解构赋值，需要单独导出，或者单独导出每个函数
// export {
//   mapState,
//   mapGetters,
//   mapMutations,
//   mapActions
// }
export default {
  install,
  Store
}